<?php
html::printPath(array(
	    'seminar.form-title' => 'admin/seminar/all',
	    $seminar['name'] => '/admin/seminar/display?id=' . $seminar['id'],
		'seminar.accommodation-title' => 'admin/seminarAccomodation/overview',
	    'seminar.roomUsage-title' => ''
	),
	'seminar-roomUsage-desc'
);
$msg->printMessages();

$CELL_WIDTH = 60;
$CELL_PADDING = 10;

echo '<table class="listTable roomUsageTable" style="width: ' . (count($seminarDays) * ($CELL_WIDTH + $CELL_PADDING) * 2) . 'px">';

echo '<thead>';
foreach ($seminarDays as $timestamp) {
	echo '<th colspan="2">' . format::date($timestamp) . '</th>';
}
echo '</thead>';

echo '<tbody>';
foreach ($roomUsageModel as $daySequence) {
	echo '<tr>';
	echo '<td class="unused">&nbsp;</td>';
	$dayIndex = 0;
	for ($dayIndex = 0; $dayIndex < count($daySequence); ) {
		$registration = $daySequence[$dayIndex];
		if (! $registration) {
			echo '<td colspan="2" class="unused">&nbsp;</td>';
			$dayIndex += 1;
		}
		else {
			$nightCount = date::nightCount($registration['batch_begin_date'], $registration['batch_end_date']);
			echo '<td style="width:' . (2 * $CELL_WIDTH * $nightCount + ($CELL_PADDING * ($nightCount - 1))) . 'px" colspan="' . (2 * $nightCount) . '">' . html::popup('/admin/registration/display?id=' . $registration['id'], $registration['id']) . ' ' . format::personFullName($registration) . '</td>';
			$dayIndex += $nightCount;
		}
	}
	echo '<td class="unused">&nbsp;</td>';
	echo '</tr>';
}
echo '</tbody>';
echo '</table>';
